﻿using System.Windows;
using VisionDesigner;
using VM.Controls;
using VM.Core;

namespace VM.Scheme
{
    public class DefaultImageProcessor : IImageProcessor
    {
        // 自动属性实现 DisplayControl
        public DisplayControl _displayControl { get; private set; }

        public DefaultImageProcessor(DisplayControl displayControl)
        {
            _displayControl = displayControl;
        }

        public void ProProcess()
        {
            if (_displayControl.m_ROI != null)
            {
                _displayControl.RemoveShape(_displayControl.m_ROI);
                _displayControl.m_ROI = null;
            }
        }

        public void ProcessImage(CMvdImage image)
        {
            // 异步更新到 UI，确保线程安全
            Application.Current.Dispatcher.Invoke(() =>
            {
                _displayControl.Image = image;
            });
        }

        public void BindEvents()
        {
            _displayControl.ROIShapeCreated += _displayControl_ROIShapeCreated;
        }


        public void UnbindEvents()
        {
            _displayControl.ROIShapeCreated -= _displayControl_ROIShapeCreated;
        }

        private void _displayControl_ROIShapeCreated(object? sender, ROIShapeEventArgs e)
        {

        }

    }
}
